<template>
	<view class="setUp">
		<view class="navBox">
			<image src="/static/pages/index/bgImg.png" class="bgImg" mode=""></image>
			<view class="navBox1">
				<view class="title">
					
					<image src="/static/pages/index/icon_back_lift.png" mode="" class="icon_back_lift" @click="backClick"></image>
					<view class="navWord">我的</view>
				</view>
				<view class="navImg">
					<image :src="avatar" class="tx" mode=""></image>
					<!-- <image src="../../static/pages/index/img_aviter.png" mode=""></image> -->
				</view>
				<view class="nickName">
					{{nickname}}
				</view>
			</view>
		</view>
		<view class="list">
			<view class="li" @click="navto" data-url='set_name'>
				<view class="li_1">
					昵称
				</view>
				<view class="li_2">
					<view class="li_2_1">
						{{nickname == ''?'未填写':nickname}}
					</view>
					<image class="li_2_2" src="../../static/pages/index/right.png" mode=""></image>
				</view>
			</view>
			<view class="li"  data-url='set_xingming'>
				<view class="li_1">
					姓名
				</view>
				<view class="li_2">
					<view class="li_2_1">
						{{name == "" ? "暂无" : name}}
					</view>
					<!-- <image class="li_2_2" src="../../static/pages/index/right.png" mode=""></image> -->
				</view>
			</view>
			<view class="li"  data-url='set_xingbie'>
				<view class="li_1">
					性别
				</view>
				<view class="li_2">
					<view class="li_2_1">
						{{gender == "" ? "暂无" : gender}}
					</view>
					<!-- <image class="li_2_2" src="../../static/pages/index/right.png" mode=""></image> -->
				</view>
			</view>
			<view class="li" data-url='set_mobile'>
				<view class="li_1">
					手机号
				</view>
				<view class="li_2">
					<view class="li_2_1">
						{{mobile == "" ? "暂无" : mobile}}
					</view>
					<!-- <image class="li_2_2" src="../../static/pages/index/right.png" mode=""></image> -->
				</view>
			</view>
			<view class="li"  data-url='set_mendian'>
				<view class="li_1">
					门店
				</view>
				<view class="li_2">
					<view class="li_2_1">
						{{store_name == "" ? "暂无" : store_name}}
					</view>
					<!-- <image class="li_2_2" src="../../static/pages/index/right.png" mode=""></image> -->
				</view>
			</view>
			<!-- <view class="li"  data-url='set_quyu'>
				<view class="li_1">
					区域
				</view>
				<view class="li_2">
					<view class="li_2_1">
						{{regional == "" ? "暂无" : regional}}
					</view>
					<image class="li_2_2" src="../../static/pages/index/right.png" mode=""></image>
				</view>
			</view> -->
		</view>
		<view class="tuideng">
			<view class="" @click="tuichu">
				退出登录
			</view>
		</view>
		<view class="zhezhao" v-if="tui">
			<view class="kuang">
				<image class="cha" src="../../static/pages/index/cloose.png" mode="" @click="tuiding"></image>
				<view class="kuang_title">确定要退出登录吗</view>
				<view class="liecan">
					<view class="qu" @click="tui = false">取消</view>
					<view class="que" @click="que_ding">确定</view>				
				</view>			
			</view>
		</view>
	</view>
</template>

<script>
	import {profile,login} from '@/request/api.js'
	export default {
		data() {
			return {
				tui:false,  //遮罩层
				avatar:"",
				nickname:'',
				name:'',
				gender:'',
				mobile:'',
				store_name:'',
				regional:'',
			};
		},
		onLoad() {
			this.formList()
			this.$forceUpdate()
		},
		onShow() {
			this.$forceUpdate()
		},
		watch:{
		    //监听reFresh,如果有修改就执行监听器
		    reFresh:function(){
		      // 调初始化页面的接口
		        this.formList()
		        console.log("页面已重新加载");
		    }
		},
		methods:{
			que_ding(){
				uni.clearStorageSync('login')
				uni.reLaunch({
					url:'/pages/index/choice'  //选择dlr 、区域
				})
				
			},
			formList(){
				if(uni.getStorageSync("login")){
					this.avatar = 'https://dy.nuofenggr.com/' +  uni.getStorageSync("login").avatar
					// this.nickname = uni.getStorageSync("login").nickname
					this.name = uni.getStorageSync("login").name				
				}else{
					this.avatar = '../../static/pages/index/img_aviter.png'
					// this.nickname = uni.getStorageSync("login").nickname
					this.name = '未登录'
				}
					
				if(uni.getStorageSync("login").gender == 1){
					this.gender = "男"
				}else if(uni.getStorageSync("login").gender == 2){
					this.gender = "女"
				}
				this.mobile = uni.getStorageSync("login").mobile
				this.store_name = uni.getStorageSync("login").store_name
				this.regional = uni.getStorageSync("login").regional
				let a = uni.getStorageSync('mobile')
				let b = uni.getStorageSync('password')
				let data={
					account:a,
					password:b,
					type:2
				}
				login(data).then(res=>{
					console.log(res,"登录登录")
					this.nickname = res.data.nickname
					uni.setStorageSync('login',res.data)
				}).catch(err=>{
					
				})
			},
			tuichu:function(){
				this.tui=true
				
			},
			
			tuiding:function(){
				this.tui = false
			},
			
			
			navto:function(e){
				var a=e.currentTarget.dataset
				uni.navigateTo({
					url:a.url
				})
				
				
			},
			
			
			backClick(){
				uni.navigateBack({
					delta:1
				})
			}
		}
	}
</script>

<style lang="scss">
	
	.zhezhao{
		background: rgba(0,0,0,0.3);
		width: 100%;
		height: 100vh;
		position: fixed;
		top: 0;
		display: flex;
		align-items: center;
		justify-content: center;
		.kuang{
			padding: 68rpx;
			background: #FFFFFF;
			margin: 0 40rpx;
			width: 100%;
			border-radius: 32rpx;
			position: relative;
			.cha{
				position: absolute;
				top: 20rpx;
				right: 20rpx;
				width: 30rpx;
				height: 30rpx;
			}
			.kuang_title{
				text-align: center;
			}
			.liecan{
				display: flex;
				align-items: center;
				justify-content: space-around;
				margin-top: 80rpx;
				.qu{
					padding: 20rpx 70rpx;
					background: rgba(24, 85, 246, 1);
					font-size: 30rpx;
					border-radius: 3000rpx;
					color: #fff;
				}
				.que{
					padding: 20rpx 70rpx;
					background: rgba(216, 222, 240, 1);
					font-size: 30rpx;
					border-radius: 3000rpx;
					color: rgba(24, 85, 246, 1);
				}
			}
		}
		
	}
	.tuideng{
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top: 100rpx;
		view{
			width: 340rpx;
			height: 80rpx;
			line-height: 80rpx;
			border-radius: 1000px;
			background: #1855F6;
			font-size: 30rpx;
			color: #fff;
			text-align: center;
		}
	}
	page {
		background-color: #FFFFFF;
	}
	.li{
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 35rpx 42rpx;
		border-bottom: 1px solid rgba(138, 142, 153, 0.2);	
		.li_1{
			font-size: 34rpx;
			color: #303133;
			
		}
		.li_2{
			display: flex;
			align-items: center;
			
			.li_2_1{
				font-size: 26rpx;
				color: #909299;
				margin-right: 20rpx;
			}
			.li_2_2{
				width: 23rpx;
				height: 38rpx;
			}
			
		}
	}
.setUp{
	width: 100%;
	box-sizing: border-box;
	padding-bottom: 40rpx;
	.navBox{
		width: 100%;
		height: 400rpx;
		position: relative;
		.bgImg{
			width: 100%;
			height: 100%;
		}
		.navBox1{
			width: 100%;
			height: 100%;
			position: absolute;
			// top: calc(var(--status-bar-height) + 10rpx);
			top: 0;
			left: 0;
			overflow: hidden;
			.title{
				width: 100%;
				margin-top:calc(var(--status-bar-height) + 30rpx);
				justify-content: space-between;
				position: relative;
				.icon_back_lift{
					width: 22rpx;
					height: 38rpx;
					margin-left: 40rpx;
					position: absolute;
					top: 5rpx;
					left: 10rpx;
				}
				.navWord{
					width: 100%;
					text-align: center;
					font-size: 40rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #FFFFFF;
					margin: 0 auto;
				}
			}
			.navImg{
				width: 100%;
				display: flex;
				justify-content: space-around;
				margin-top: 55rpx;
				.tx{
					width: 100rpx;
					height: 100rpx;
					border-radius: 50%;
				}
			}
			.nickName{
				font-size: 36rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #FEFEFE;
				text-align: center;
				margin-top: 24rpx;
			}
		}
	}
}
</style>
